<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <script>
        /*  找一个字符串重复最多的内容，显示重复多少次 */

        /*  1.找到每个字符出现的次数； */
        function getstrobj(str) {
            var obj = {};
            for (var i = 0; i < str.length; i++) {
                var k = str[i];
                if (typeof obj[k] == "undefined") {
                    obj[k] = 1;
                } else {
                    obj[k]++;
                }
            }
            return obj;
        }
        var str = "aaaabbbbccccdde";
        var res = getstrobj(str);
        console.log(res);

        //用来存放结果的对象
        var objData = [{
            num: 0,
            name: "a",
        }, ];

        for (var k in res) {
            if (res[k] > objData[objData.length - 1]["num"]) {
                objData[objData.length - 1]["num"] = res[k];
            }
        }
    </script>
</body>

</html>